package com.museum.controller;

import com.alibaba.fastjson.JSONObject;
import com.museum.base.BaseApiService;
import com.museum.base.BaseResponse;
import com.museum.controller.APi.ExcavationAPI;

import com.museum.entity.message.ExcavationInformation;

import com.museum.service.impl.ExcavationServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;

/**
 * <p>
 * 前端控制器
 * </p>
 *
 * @author Ruiwen/yznl
 * @since 2021-01-05
 */


@RestController
@RequestMapping("/excavation")
public class ExcavationController extends BaseApiService<JSONObject> implements ExcavationAPI {
    @Autowired
    private ExcavationServiceImpl excavationService;
/*
* 提交挖掘信息
* */
    @Override
    public BaseResponse<JSONObject> addExcavation(ExcavationInformation excavationInformation, HttpServletRequest request) {
        int result = excavationService.addExcavationInfo(excavationInformation,request);
        if(result>0){
            return setResultSuccess("添加成功");
        }else{
            return setResultError("添加失败");
        }
    }
/*
* 条件查询挖掘查询
* */
    @Override
    public BaseResponse<JSONObject> getAllExcavationByPage(long current, long limit, ExcavationInformation excInfo) {
        JSONObject json = excavationService.getAllExcInfoByPage(current,limit,excInfo);
        return setResultSuccess(json);
    }

    @Override
    public BaseResponse<JSONObject> deleteExcById(Integer id) {
        int result = excavationService.deleteExcInfoById(id);
        if(result>0){
            return setResultSuccess("删除成功");
        }else{
            return setResultError("删除失败");
        }
    }

//    @Override
//    public BaseResponse<JSONObject> updateExcById(Integer id) {
//
//        return null;
//    }
}
